package main

import (
	"fmt"
	"sort"
)

func main() {
	var a = make([]int, 5, 10) //创建一个切片，长度我5，容量为10
	fmt.Printf("a=%v len(a)=%d cap(a)=%d \n", a, len(a), cap(a))
	for i := 0; i < 10; i++ {
		a = append(a, i)
	}
	fmt.Printf("a=%v len(a)=%d cap(a)=%d \n", a, len(a), cap(a))

	var c = make([]int, 0) //创建一个切片，长度为0，容量为0
	fmt.Printf("c=%v len(c)=%d cap(c)=%d \n", c, len(c), cap(c))
	for i := 0; i < 10; i++ {
		c = append(c, i)
	}
	fmt.Printf("c=%v len(c)=%d cap(c)=%d \n", c, len(c), cap(c))

	var b []int
	fmt.Printf("b=%v len(b)=%d cap(b)=%d \n", b, len(b), cap(b))
	for i := 0; i < 10; i++ {
		b = append(b, i)
	}
	fmt.Printf("b=%v len(b)=%d cap(b)=%d \n", b, len(b), cap(b))

	//sort排序
	var a1 = [...]int{3, 7, 8, 4, 1}
	sort.Ints(a1[:]) //对切片进行排序
	fmt.Println(a1)

}
